package vistas.rodamientos;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import app.Odv;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class BajaRodamientoFrame extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel jLabel1;
	private JComboBox jComboBox1;
	private JButton jButton1;
	private JButton jButton2;
	private JTextArea jTextArea1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				BajaRodamientoFrame inst = new BajaRodamientoFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public BajaRodamientoFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("NUMERO DE RODAMIENTO:");
				jLabel1.setBounds(12, 26, 150, 16);
			}
			{
				
				
				
						
				jComboBox1 = new JComboBox();
				getContentPane().add(jComboBox1);
				
				Odv s = Odv.getinstancia();
				List<Integer> lista = s.rodamientosId();
				for(int id:lista)
					jComboBox1.addItem(id);
				
				jComboBox1.setBounds(193, 26, 54, 23);
				jComboBox1.addActionListener(new ActionListener() {
				
					
					
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jComboBox1.actionPerformed, event="+evt);
						Odv s= Odv.getinstancia();
						
						jTextArea1.setText(s.getRodamiento((Integer) jComboBox1.getSelectedItem()).toString());
						
					}
				});
			}
			{
				jTextArea1 = new JTextArea();
				getContentPane().add(jTextArea1);
				jTextArea1.setBounds(0, 100, 384, 127);
			}
			{
				jButton1 = new JButton();
				getContentPane().add(jButton1);
				jButton1.setText("DAR DE BAJA");
				jButton1.setBounds(6, 283, 96, 23);
				jButton1.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButton1.actionPerformed, event="+evt);
						Odv s= Odv.getinstancia();
						s.eliminarRodamiento((Integer) jComboBox1.getSelectedItem());
						jTextArea1.setText("");
						jComboBox1.removeItem(jComboBox1.getSelectedItem());
						SeDioDeBajaRodamientoFrame v= new SeDioDeBajaRodamientoFrame();
						v.setVisible(true);
						v.setLocationRelativeTo(null);
					}
				});
			}
			{
				jButton2 = new JButton();
				getContentPane().add(jButton2);
				jButton2.setText("SALIR");
				jButton2.setBounds(172, 283, 65, 23);
				jButton2.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButton2.actionPerformed, event="+evt);
						dispose();
					}
				});
			}
			pack();
			this.setSize(400, 349);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
